<template>
     <van-action-bar>  
            <van-action-bar-icon icon="chat-o" text="客服" @click="onClickIcon" color="pink"/>
            <van-action-bar-icon icon="cart-o" text="购物车" @click="onClickIcon" />
            <van-action-bar-icon icon="shop-o" text="店铺" @click="onClickIcon" color="pink"/>
            <van-action-bar-button type="warning" text="加入购物车" color="pink" @click="addToCart"/>
            <van-action-bar-button type="danger" text="立即购买" color="pink" />
            </van-action-bar>
</template>

<script>
import { doAddCart } from '@/api/cart';
    export default {
        data(){
            return{
                userid:''
            }
        },
        methods:{
        addToCart(){
            doAddCart({userid:this.userid,proid:this.$route.params.proid,num:1}).then(res=>{
                if (res.data.code!='200') {
                    return showToast('加入购物车失败')
                }
                showToast('加入购物车成功')
                this.$router.push('/cart')
            })
        },
        onClickIcon(){
        },
        onClickButton(){
        }
        },
        created(){
            this.userid=localStorage.getItem('userid')
        }
    }
</script>

<style lang="less" scoped>

</style>